package com.wx.spider.sql.controller;

import com.wx.spider.common.model.CommonResponse;
import com.wx.spider.common.pojo.db.WxBizSpider;
import com.wx.spider.sql.service.WxBizSpiderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author:feng
 * @create:2021-04-25 16:36
 */
@RestController
@RequestMapping("/wxbizspider")
public class WxBizSpiderController {
    @Autowired
    private WxBizSpiderService wxBizSpiderService;

    @PostMapping("/save")
    private CommonResponse<WxBizSpider> save(@RequestBody WxBizSpider wxBizSpider){
        try{

            boolean flag = wxBizSpiderService.save(wxBizSpider);
            if(flag){
                return CommonResponse.succeed(wxBizSpider);
            }else{
                return CommonResponse.INTERNAL_ERROR_RESPONSE;
            }
        }catch (Exception e) {
            e.printStackTrace();
            return CommonResponse.INTERNAL_ERROR_RESPONSE;
        }
    }

    @PutMapping("/update")
    private CommonResponse<WxBizSpider> update(@RequestBody WxBizSpider wxBizSpider){
        try{

            boolean flag = wxBizSpiderService.updateById(wxBizSpider);
            if(flag){
                return CommonResponse.succeed(wxBizSpider);
            }else{
                return CommonResponse.INTERNAL_ERROR_RESPONSE;
            }
        }catch (Exception e) {
            e.printStackTrace();
            return CommonResponse.INTERNAL_ERROR_RESPONSE;
        }
    }
}
